import request from '../utils/request'

/**
 * 生成验证码
 */
export function generateCaptcha(type = 'image') {
  return request({
    url: '/captcha/generate',
    method: 'get',
    params: { type }
  })
}

/**
 * 验证验证码
 */
export function verifyCaptcha(captchaId, userInput) {
  return request({
    url: '/captcha/verify',
    method: 'post',
    data: { captchaId, userInput }
  })
}

/**
 * 验证滑块验证码
 */
export function verifySliderCaptcha(captchaId, x) {
  return request({
    url: '/captcha/verify-slider',
    method: 'post',
    data: { captchaId, x }
  })
}

/**
 * 检查是否需要验证码
 */
export function isCaptchaRequired(type) {
  return request({
    url: '/captcha/required',
    method: 'get',
    params: { type }
  })
}

/**
 * 刷新验证码
 */
export function refreshCaptcha(type = 'image', captchaId = null) {
  return request({
    url: '/captcha/refresh',
    method: 'post',
    data: { type, captchaId }
  })
}

/**
 * 获取验证码配置状态
 */
export function getCaptchaConfigStatus() {
  return request({
    url: '/admin/system-config/captcha/status',
    method: 'get'
  })
}
